Answers for SCWCD / OCWCD Online Test - Online Exam - Online Quiz - Mock Test
←Go Back to Online Practice TestQues. Which of the following statements is true regarding MyServlet? import javax.servlet.*; import javax.servlet.http.*: import java.io.*; public class MyServlet extends HttpServlet implements SingleThreadModel { String myName; public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { response.setContentType("text/plain"); PrintWriter out = res.getWriter(); myName = req.getParameter("name"); sayHello(out); out.close(); } public void sayHello(PrintWriter out) { out.println("Hello " + myName); } } |
Option 1. MyServlet is thread safe |
Option 2. MyServlet is not thread safe because myName is an instance variable |
Option 3. MyServlet is not thread safe because MyServlet implements SingleThreadModel. |
Option 4. None of the above |
Ans. Option 1 |
Please provide the reason below. The best provided reason will be displayed with your name(if you are logged-in) on website. |
Enter Reason |
Is it helpful?
Yes
No